using System;
using System.Web.Mvc;
using MvcCmsForum.Service;
using MvcCms.Service;
using MvcCms.Service.Logging;

namespace MvcCmsForum.Controllers
{
    public class MvcCmsForumAjaxController : MvcCms.Service.Code.BaseClasses.MvcCmsControllerBase
    {
        #region Constructors

        private readonly IForumService _forumService;

        public MvcCmsForumAjaxController(IForumService forumService)
        {
            _forumService = forumService;

        }

        #endregion

        public JsonResult GetAllForumsLatestPosts()
        {
            try
            {
                var comments = _forumService.ListPosts();
                return Json(comments);
            }
            catch (Exception ex)
            {
                AppLogging.GetLogger().Error(ex.Message, ex);
                return Json(new { error = ex.Message });
            }
        }

    }
}